<%@ page import="com.servlet.demo.dto.User" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: liulei
  Date: 2019/12/4
  Time: 20:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>用户列表</title>
</head>
<body>
<div>
    <h1>2种遍历列表的方法：</h1>
    <table>
        <tr>
            <td colspan="5"><h3>1、纯java：</h3></td>
        </tr>
        <tr>
            <th>用户ID</th>
            <th>账号</th>
            <th>密码</th>
            <th>用户类型</th>
            <th>操作</th>
        </tr>
        <%
            List<User> list = (List<User>) request.getAttribute("list");
            if (list != null && list.size() >0) {
                for (int i = 0; i < list.size(); i++) {
                    User u = list.get(i);
                    %><tr><%
                        %><td><%=u.getUserId()%></td><%
                        %><td><%=u.getAccount()%></td><%
                        %><td><%=u.getPassword()%></td><%
                        %><td><%=u.getUserType().name()%></td><%
                        %><td><a href="/user/detail.do?id=<%=u.getUserId()%>">查看详情</a></td><%
                    %></tr><%
                }
            }
        %>
        <tr>
            <td colspan="5"><h3>2、jstl混合el表达式：</h3></td>
        </tr>
        <c:forEach items="${list}" var="u">
            <tr>
                <td>${u.userId}</td>
                <td>${u.account}</td>
                <td>${u.password}</td>
                <td>${u.userType.name()}</td>
                <td><a href="/user/remove.do?id=${u.userId}">删除</a></td>
            </tr>
        </c:forEach>
    </table>



</div>
</body>
</html>
